<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="css/mui.min.css" rel="stylesheet" />
	</head>

	<body>
		<form class="mui-input-group" id="input_example">
			<div class="mui-input-row">
				<label>用户名</label>
				<input type="text" id="username" name="username" placeholder="请输入用户名" value="123">
			</div>
			<div class="mui-input-row">
				<label>密码</label>
				<input type="password" id="password" name="password" class="mui-input-password" placeholder="请输入密码">
			</div>
			<div class="mui-button-row">
				<button type="button" id="login" class="mui-btn mui-btn-primary">确认</button>
				<button type="button" class="mui-btn mui-btn-danger">取消</button>
			</div>
		</form>
	</body>
	<script src="js/mui.min.js"></script>
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" charset="utf-8">
		(function($, doc, $$) {
			$.init();
			$(".mui-button-row").on("tap", "#login", foo_1);

			function foo_1() {
				var username = $$('#username').val();
				var userpass = $$('#password').val();
				var url = 'http://47.105.181.78:8281/user/login';
				//var url = 'http://localhost:8281/user/login';
				var type = 'POST';
				var data = {
					'username': username,
					'password': userpass
				};
				var dataType = 'jsonp';
				mui.ajax(url, {
					type: type,
					data: JSON.stringify(data),
					dataType: dataType,
					timeout: 1000,
					headers: {
						'Access-Control-Allow-Origin': '*',
						'Content-Type': 'application/json; charset=UTF-8'
					},
					success: function(data) {
						/*alert(data);*/
						if("success" === data) {
							$.openWindow({
								url: 'index.html',
								id: 'index'
							});
						}
					},
					error: function(xhr, type, errorThrown) {
						mui.alert(type);
					}
				});
			}
		}(mui, document, jQuery));
	</script>

</html>